<script type="text/javascript">
{literal}
	$(document).ready(function() {
		
	});
	function saveParaConfig() {
		var data4Save = getdataforSave();
		showMessage('statusMessage', '', 'success');
		$.ajax({
	        type:       "POST",
	        url:        "../ParacliniqueConfig/SaveAjax?set_ajax_view",
	        data:       data4Save,       
	        dataType:   "json",     
	        success:    function(data) {

		        if (data.error.code ==  'OK') {		            
		            showMessage('statusMessage', _('Save successful'), 'success');
		            
		        } else {
		            displayError(data.error.mess);              
		        }
	            
	        }
	    }); 
	}
	function getdataforSave() {
		var data ='';

		$("#paraCliniqueueConfig tbody tr").each( function() {
			var id = $(this).attr("id");
			var roomId = $('select#room' + id + ' :selected').val();
			var paymentType = $('select#payment' + id + ' :selected').val();
			data += '&paraEnum[]=' + id;
			data += '&roomId[]=' + roomId;
			data += '&paymentType[]=' + paymentType;
		});
		return data;
	}
{/literal}
</script>

<div style="width: 550px;" class="form_container">
<span id="statusMessage">&nbsp;</span>
<br>
<span class="label">{translate}Paraclinique config{/translate}</span>
<br>
<table id="paraCliniqueueConfig" class="grid" cellspacing="0" cellpadding="0">
	<thead>
		<tr>
			<th width="100px;">{translate}Name{/translate}</th>
			<th width="100px;">{translate}Room{/translate}</th>
			<th width="100px;">{translate}Payment type{/translate}</th>
		</tr>
	</thead>
	<tbody>
	   {foreach from=$paraList item=item key=id}   
	       <tr id ="{$id}">
	           <td>{$item}</td>
	           <td>
		           <select id="room{$id}">
                       {html_options options=$listRooms selected=$paraConfigList.$id.room_id}
                   </select>
	           </td>
	           <td>
	               <select id="payment{$id}">
                      {html_options options=$paymentTypes selected=$paraConfigList.$id.enum_payment_type}
                   </select>		           
	           </td>
	       </tr>            
       {/foreach}	   	
	</tbody>
</table>
<div style="text-align: right;">
<input type="button" value="{translate}Save{/translate}" onclick="javascript:saveParaConfig();">
</div>
</div>

